Universal Serial Bus (USB) networks are well known in the art. A USB network consists of one or more USB devices (e.g., printer, scanner, fax machine, etc.) connected directly to a USB host (e.g., a desk top computer) or indirectly to the USB host via a hub. There is only one USB host in any USB network. It is noted that communication between a USB host and a USB device can occur via a hub that attaches multiple USB devices to the USB host. A USB device may implement multiple functions which communicate with the USB host via a USB cable/connection. A multiple function USB device is known as a compound USB device. An example of a compound USB device is one that can function as a fax machine, a printer, or a scanner. A USB hub may also be included in the compound USB device.
Communication between USB host and USB devices is defined by the USB specification. The USB specification was developed by the personal computer (PC) industry. The USB specification is described in detail in the Universal Serial Bus Specification, Revision 1.1, and published Sep. 23, 1998, and Universal Serial Bus Specification, Revision 2.0 published Apr. 27, 2000, the contents of which are incorporated herein by reference in their entirety. USB host and USB devices communicate via bus transactions transmitted over a USB cable/connection. All bus transactions in the USB network involve the transmission of up to three packets between the USB host and USB device: a token packet, a data packet, and an optional transaction-complete packet. Each transaction begins when the USB host, on a scheduled basis, sends a USB token packet describing the type and direction of transaction (i.e., whether data is transmitted to the USB device from the USB host or to the USB host from the USB device), a USB device address, and an endpoint number. Each USB device has one or more endpoints designated by respective endpoint numbers. An endpoint is the ultimate source or destination for data of the data transaction. The USB device that is addressed by the token packet selects itself by decoding the appropriate address fields of the token packet. After the token packet is transmitted, data is then transferred in the data packet either from the USB host to a USB device or from a USB device to the USB host. The direction of data transfer is specified in the token packet. The destination of the transaction then sends the transaction-complete packet indicating whether data transfer was successful.
USB permits reliable communication. It can detect errors and recover from errors based on transaction type. Most transactions like, control, interrupt and bulk transaction types, require data integrity and they uses use error detection and retry. Isochronous transactions do not use retries due to delivery in time characteristic and may tolerate a higher incidence of uncorrected errors. Hence, the transaction-complete packet is not used to acknowledge the successful completion of the isochronous transaction.
FIG. 1 illustrates a USB network 10 consisting of a USB host 12 connected to a single USB device 14 via a USB cable/connection 16. For purposes of explanation, it is presumed that USB device 14 is a compound device capable of acting as a fax machine, a printer, or a scanner at any point in time. Moreover, USB device 14 includes N endpoints that are the ultimate source or destination for data of data transactions with the USB host 12. Although the present invention will be described with reference to a USB network having a USB host and a single USB device, it is understood that the present invention is not limited thereto.
FIG. 2 illustrates relevant components of a circuit 18 within USB device 14 shown in FIG. 1. More particularly, FIG. 2 shows in block diagram form, memory (e.g., RAM memory) 20 coupled between an endpoint controller 22 and a backend interface 24. Endpoint controller 22 and backend interface 24 may take form in software running on one or more embedded processors (not shown) within USB device 14. Both endpoint controller 22 and backend interface 24 are configured to access (read or write) data in memory 20. Endpoint controller 22 is coupled to USB host 12 (not shown in FIG. 2) and is configured to receive or send packets, including data packets, from the USB host 12. Backend interface 24 communicates with each of the endpoints of USB device 14 and is configured to receive or send data to the endpoints.
Memory 20 is configured as a set of endpoint buffers designated endpoint buffers 1–N corresponding to endpoints 1–N, respectively, of USB device 14. Endpoint buffers 1–N temporarily store data of endpoints 1–N, respectively, transmitted between endpoints of USB device 14 and USB host 12. To illustrate, endpoint controller 22 may receive a token packet identifying endpoint 2 of USB device 14 as the ultimate sink of new data that will be subsequently transmitted by USB host 12. Upon receipt of the token packet, a data packet is sent from USB host 12 containing endpoint 2 data for storage in endpoint buffer 2. Endpoint controller 22 determines whether endpoint buffer 2 has sufficient memory for receiving the new data. If endpoint controller 22 determines that endpoint buffer 2 has sufficient memory space, endpoint controller 22 sends an acknowledgement packet back to USB host 12. In response, a data packet is sent from USB host 12 containing endpoint 2 data for storage in endpoint buffer 2. Then then endpoint controller 22 sends an acknowledgement packet back to USB host 12 indicating the status of success or failure for the data transfer. When the data transaction from USB host 12 to endpoint controller 22 has finished, endpoint controller 22 alerts backend interface 24 that endpoint buffer 2 contains new data. Eventually, backend interface 24 reads and forwards data contained within endpoint buffer 2 to the backend embedded processor or any application specific hardware of USB device 14.
Each of the endpoints in device 14 is permanently assigned a particular endpoint buffer within memory 20. The size of each endpoint buffer is predetermined. Once the buffer size is set, the buffer size cannot be changed. Data packets transmitted between USB host 12 and an endpoint of USB device 14 may vary in size. Each endpoint buffer in memory 20 should be sized to store data of the largest data packet transmitted between the USB host 12 and USB device 14 endpoint. If an endpoint buffer lacks sufficient size to store data of a transaction, the data transaction cannot be completed. Additionally, the buffer allocated to an endpoint may be large, but the buffer may have little memory space available to store new data as a result of delays in reading the existing data in the buffer. If an endpoint buffer lacks sufficient space to store data of a transaction, again, the data transaction cannot be completed.
To avoid this, the endpoint buffers are usually over sized or sized to store the transaction maximum packet size between USB host 12 and the endpoint of the USB device 14. However, the cost to manufacture USB device 14 is proportional to the size of memory 20. Thus, the greater the size of endpoint buffers 1–N in memory 20, the greater the cost of memory 20 and the greater the cost of USB device 14. Accordingly, a conflict exists between designing USB devices with large memories 20 and designing USB devices that are inexpensive.